/*
 * Copyright 2009 Gordon Turner
 * 
 * This file is part of openwiimote.
 *
 * openwiimote is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * openwiimote is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public License
 * along with Wiimote Simple.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.openwiimote.listeners;

import org.apache.log4j.Logger;
import org.openwiimote.event.WiiAccelEvent;
import org.openwiimote.event.WiiButtonEvent;
import org.openwiimote.event.WiiIrEvent;
import org.openwiimote.event.WiimoteListener;

/**
 * @author gturner
 *
 */
public class WiimoteListenerImpl implements WiimoteListener
{
  Logger logger = Logger.getLogger( WiimoteListenerImpl.class );

  public boolean buttonAPressed = false;

  public boolean buttonBPressed = false;

  public boolean button1Pressed = false;

  public boolean button2Pressed = false;

  public boolean buttonLeftPressed = false;

  public boolean buttonRightPressed = false;

  public boolean buttonDownPressed = false;

  public boolean buttonUpPressed = false;

  public boolean buttonMinusPressed = false;

  public boolean buttonPlusPressed = false;

  public boolean buttonHomePressed = false;

  /* (non-Javadoc)
   * @see org.openwiimote.event.WiimoteListener#wiiAccelInput(org.openwiimote.event.WiiAccelEvent)
   */
  public void wiiAccelInput( WiiAccelEvent wiiAccelEvent )
  {
    logger.debug( "wiiAccelInput received." );
  }

  /* (non-Javadoc)
   * @see org.openwiimote.event.WiimoteListener#wiiButtonChange(org.openwiimote.event.WiiButtonEvent)
   */
  public void wiiButtonChange( WiiButtonEvent wiiButtonEvent )
  {
    logger.debug( "wiiButtonChange received." );

    if( wiiButtonEvent.isAPressed() )
    {
      logger.debug( "A Button pressed." );
      buttonAPressed = true;
    }
    else if( wiiButtonEvent.isBPressed() )
    {
      logger.debug( "B Button pressed." );
      buttonBPressed = true;
    }
    else if( wiiButtonEvent.is1Pressed() )
    {
      logger.debug( "1 Pressed." );
      button1Pressed = true;
    }
    else if( wiiButtonEvent.is2Pressed() )
    {
      logger.debug( "2 Pressed." );
      button2Pressed = true;
    }
    else if( wiiButtonEvent.isLeftPressed() )
    {
      logger.debug( "Left Pressed." );
      buttonLeftPressed = true;
    }    
    else if( wiiButtonEvent.isRightPressed() )
    {
      logger.debug( "Right Pressed." );
      buttonRightPressed = true;
    }    
    else if( wiiButtonEvent.isDownPressed() )
    {
      logger.debug( "Down Pressed." );
      buttonDownPressed = true;
    }    
    else if( wiiButtonEvent.isUpPressed() )
    {
      logger.debug( "Up Pressed." );
      buttonUpPressed = true;
    }
    else if( wiiButtonEvent.isMinusPressed() )
    {
      logger.debug( "Minus Pressed." );
      buttonMinusPressed = true;
    }    
    else if( wiiButtonEvent.isPlusPressed() )
    {
      logger.debug( "Plus Pressed." );
      buttonPlusPressed = true;
    }    
    else if( wiiButtonEvent.isHomePressed() )
    {
      logger.debug( "Home Pressed." );
      buttonHomePressed = true;
    }

  }

  /* (non-Javadoc)
   * @see org.openwiimote.event.WiimoteListener#wiiIRInput(org.openwiimote.event.WiiIREvent)
   */
  public void wiiIRInput( WiiIrEvent wiiIREvent )
  {
    logger.debug( "wiiIRInput received." );
  }

}
